<template>
  <view class="product-details">
    <!-- 顶部图片加搜索框 -->
    <view class="top-img-box" :style="{width: imgWidth, height: imgWidth, paddingTop: padTop}">
      <view class="input-box">
        <view class="back" @tap="goBack"><uni-icons type="left" color="#ffffff" /> </view>
        <view class="search">
          <uni-icons type="search" size="14" color="#ffffff" />
          <input type="text" placeholder="搜索地标" />
        </view>
      </view>
      <view class="swiper">
        <swiper :interval="3000" :duration="1000" :style="{width: imgWidth, height: imgWidth}">
          <swiper-item>
            <image src="../../static/icon/d01.png" :style="{ width: imgWidth, height: imgWidth }"/>
          </swiper-item>
          <swiper-item>
              <image src="../../static/icon/d01.png" :style="{ width: imgWidth, height: imgWidth }"/>
          </swiper-item>
        </swiper>
      </view>
    </view>
    <view class="content">
      
      <!-- 基础信息 -->
      <view class="goods-info">
        <!-- 价格 -->
        <view class="prices">
          <view class="price">
            <view class="new-pri"> ￥<text>29.98</text> </view>
            <view class="old-pri"> 原价398 </view>
          </view>
          <view class="collect">
            <image src="../../static/icon/productDetails/a-collect.png" />
            收藏
          </view>
        </view>
        <view class="goods-title"> 一杯还行的咖啡 </view>
        <view class="goods-num">
          <view class="xl"> 销量：<text>100+</text></view>
          <view class="yl"> 剩余数量：<text>1000件</text></view>
        </view>
        <!-- 商家信息 -->
        <view class="merchant-info">
          <view class="merchant-name"> MOMOKA咖啡店 </view>
          <view class="phone-location">
            <view class="pl-left">
              <view class="p-num">
                <uni-icons type="phone" size="14" color="#999999" />
                13636363636
              </view>
              <view class="l-info">
                <uni-icons type="location" size="14" color="#999999" />
                <view class="dz"> 距您1.5km | 长沙市岳麓区麓谷信息港B栋255号和水水水水 </view>
              </view>
            </view>
            <view class="pl-right">
              <view class="item">
                <image src="../../static/icon/productDetails/phone.png" />
                <text> 电话 </text>
              </view>
              <view class="item">
                <image src="../../static/icon/productDetails/nav.png" />
                <text> 导航 </text>
              </view>
            </view>
          </view>
        </view>
      </view>
      <!-- 商品详情 -->
      <view class="goods-details">
        <view class="switch-bar">
          <view class="switch-item"> 详情 </view>
          <view class="switch-item"> 评价(99+) </view>
          <view class="switch-item"> 推荐 </view>
        </view>
        <view class="details">
          <image src="../../static/icon/goodsdetails.png" mode="widthFix"></image>
        </view>
        <!-- 评价 -->
        <Evaluate />
        <!-- 推荐 -->
        <view class="reco">
          <view class="reco-title"> 精选推荐 </view>
          <ProductItem />
        </view>
      </view>
    </view>
    <view class="goods-carts">
      <view class="carts-left">
        <view class="left-item" @tap="goShop">
          <image src="../../static/icon/productDetails/store.png" /> 店铺
        </view>
        <view class="left-item">
          <image src="../../static/icon/productDetails/kefu.png" /> 客服
        </view>
        <view class="left-item">
          <image src="../../static/icon/productDetails/cart.png" /> 购物车
        </view>
      </view>
      <view class="carts-right">
        <view class="right-btn"> 加入购物车 </view>
        <view class="right-btn"> 去结算 </view>
      </view>
    </view>
  </view>
</template>

<script setup>
  import { computed } from 'vue';
  import Evaluate from '@/components/Evaluate.vue'
  import ProductItem from '@/components/ProductItem.vue'
  const { safeArea, safeAreaInsets } = uni.getSystemInfoSync()
  const padTop = computed(() => {
    return safeAreaInsets.top + 3 + 'px'
  })
  const imgWidth = computed(() => {
    return safeArea.width + 'px'
  })
  const goBack = () => {
    uni.navigateBack()
  }
  const goShop = () => {
    uni.navigateTo({ url: '/pages/shop/shop' })
  }
  console.log(safeArea.width);
</script>

<style lang="scss" scoped>
.product-details {
  padding-bottom: 58px;
  .top-img-box {
    position: relative;
    .input-box {
      width: 100%;
      position: absolute;
      top: 3px;
      left: 0;
      display: flex;
      padding: 0 22px 0 10px;
      z-index: 9;
      box-sizing: border-box;
      .back {
        width: 28px;
        height: 28px;
        line-height: 28px;
        text-align: center;
        background: rgba(0,0,0,0.6);
        border-radius: 50%;
        margin-right: 11px;
      }
      .search {
        flex: 1;
        display: flex;
        align-items: center;
        padding: 0 10px;
        height: 32px;
        background: rgba(255,255,255,0.3);
        border-radius: 170px;
        input {
          margin-left: 10px;
        }
        .uni-input-placeholder {
          color: #ffffff;
          font-size: 14px;
        }
      }
    }
  }
  .content {
    transform: translateY(-10px);
  }
  // 基本信息
  .goods-info {
    background: rgba(255,255,255,0.9);
    border-radius: 10px 10px 0px 0px;
    padding: 11px;
    box-sizing: border-box;
    .prices {
      display: flex;
      justify-content: space-between;
      margin-bottom: 8px;
      .price {
        align-items: center;
        display: flex;
        .new-pri {
          font-size: 14px;
          color: #FF3B1E;
          font-weight: bold;
          text {
            font-size: 20px;
          }
        }
        .old-pri {
          height: 11px;
          margin-left: 10px;
          font-size: 11px;
          color: #AAAAAA;
          text-decoration-line: line-through;
        }
      }
      .collect {
        display: flex;
        align-items: center;
        font-size: 12px;
        color: #333333;
        image {
          width: 20px;
          height: 20px;
          margin-right: 4px;
        }
      }
    }
    .goods-title {
      height: 19px;
      font-weight: bold;
      font-size: 16px;
      color: #222222;
      line-height: 19px;
    }
    .goods-num {
      padding: 10px 0;
      display: flex;
      font-weight: 400;
      font-size: 12px;
      color: #999999;
      line-height: 14px;
      border-bottom: 1px solid #EEEEEE;
      .xl, .yl {
        flex: 1;
        text {
          font-size: 12px;
          color: #333333;
        }
      }
    }
  }
  // 商家信息
  .merchant-info {
    padding-top: 10px;
    .merchant-name {
      height: 13px;
      font-size: 11px;
      color: #D68C1C;
      line-height: 13px;
    }
    .phone-location {
      display: flex;
      align-items: center;
      margin-top: 8px;
      .pl-left {
        flex: 1;
        font-size: 12px;
        color: #999999;
        .p-num {
          line-height: 19px;
        }
        .l-info {
          line-height: 19px;
          display: flex;
        }
      }
      .pl-right {
        display: flex;
        image {
          width: 28px;
          height: 28px;
        }
        .item {
          display: flex;
          flex-direction: column;
          align-items: center;
          margin-right: 20px;
          margin-left: 8px;
          &:nth-last-of-type(1) {
            margin-right: 9px;
            margin-left: 0;
          }
          text {
            margin-top: 3px;
            height: 13px;
            font-size: 11px;
            color: #666666;
            line-height: 13px;
          }
        }
      }
    }
  }
  .goods-details {
    margin-top: 10px;
    .switch-bar {
      height: 40px;
      padding: 13px 0;
      background-color: #fff;
      font-size: 14px;
      color: #555555;
      display: flex;
      position: sticky;
      left: 0;
      top: 10px;
      z-index: 9;
      box-sizing: border-box;
      .switch-item {
        position: relative;
        flex: 1;
        text-align: center;
        line-height: 14px;
        &::before {
          display: block;
          content: '';
          position: absolute;
          bottom: -12px;
          left: 50%;
          transform: translateX(-50%);
          width: 26px;
          height: 4px;
          background: linear-gradient( 360deg, #FF8508 0%, #FF4847 100%);
          border-radius: 33px;
        }
      }
    }
    .details {
      image {width: 100%;}
    }
  }
  .reco {
    padding: 0 12px;
    .reco-title {
      text-align: center;
      font-weight: 500;
      font-size: 14px;
      color: #333333;
      line-height: 21px;
      margin: 20px 0 10px;
    }
  }
  .goods-carts {
    height: 58px;
    box-sizing: border-box;
    background-color: #fff;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 10px 12px;
    display: flex;
    align-items: center;
    .carts-left {
      display: flex;
      .left-item {
        display: flex;
        flex-direction: column;
        font-size: 12px;
        color: #666666;
        margin-right: 23px;
        align-items: center;
        &:nth-last-of-type(1) {
          margin-right: 0;
        }
      }
      image {
        width: 22px;
        height: 22px;
      }
    }
    .carts-right {
      margin-left: 10px;
      flex: 1;
      display: flex;
      font-size: 16px;
      justify-content: space-between;
      .right-btn {
        width: 100px;
        height: 40px;
        border-radius: 99px;
        background: #F7BA1E;
        color: #FFFFFF;
        text-align: center;
        line-height: 40px;
        &:nth-last-of-type(1) {
          background: #FF3B1E;
        }
      }
    }
  }
}
</style>
